#include<bits/stdc++.h>
using namespace std;
const int N=100010;
const double o=1e-7;
struct node
{
    double d,v,a;
}c[N];
struct qj
{
    long long l,r;
    bool operator<(const qj t)const
    {
        if(r!=t.r)
            return r<t.r;
        return l<t.l;
    }
}q[N];
int idx;
long long n,m,L;
double V,V2;
long long p[N];
int upb(double x)
{
    int l=1,r=m+1,mid;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(x-p[mid]>=-o)
            l=mid+1;
        else if(x-p[mid]<-o)
            r=mid-1;
    }
    return l;
}
int upb2(double x)
{
    int l=1,r=m+1,mid;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(x-p[mid]>o)
            l=mid+1;
        else if(x-p[mid]<=o)
            r=mid-1;
    }
    return l;
}
int lob(double x)
{
    int l=1,r=m,mid;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(x-p[mid]>o)
            l=mid+1;
        else if(x-p[mid]<=o)
            r=mid-1;
    }
    return r;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--)
    {
        memset(q,0,sizeof q);
        idx=0;
        scanf("%lld%lld%lld%lf",&n,&m,&L,&V);
        V2=V*V;
        for(int i=0;i<n;i++)
            scanf("%lf%lf%lf",&c[i].d,&c[i].v,&c[i].a);
        for(int i=1;i<=m;i++)
            scanf("%lld",&p[i]);
        sort(p+1,p+1+m);
        for(int i=0;i<n;i++)
        {
            int l,r;
            double d=c[i].d,v=c[i].v,a=c[i].a;
            if(a<0&&v>V)
            {
                double s=(V2-(v*v))/(2*a);
                s=d+s;
                l=upb2(d);
                r=lob(s);
            }else if(a>0)
            {
                if(v>V)
                {
                    l=upb2(d);
                }else if(v<=V)
                {
                    double s=(V2-(v*v))/(2*a);
                    s=d+s;
                    l=upb(s);
                }
                r=m;
            }else if(a==0&&v>V)
            {
                l=upb2(d);
                r=m;
            }else
                continue;
            if(l<=r)
            {
                q[idx].l=l,q[idx++].r=r;
            }
        }
        sort(q,q+idx);
        // for(int i=0;i<idx;i++)
        // {
        //     printf("%lld %lld\n",q[i].l,q[i].r);
        // }
        long long ans=0,r=q[0].r;
        for(int i=1;i<idx;i++)
        {
            if(q[i].l>r)
            {
                r=q[i].r;
                ans++;
            }
        }
        ans++;
        printf("%d %lld\n",idx,m-ans);
    }
    

    return 0;
}